#define _GNU_SOURCE
#include <stdlib.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>

void sigHandler(int sig){
    printf("Recive signal %d\n", sig);
}

int main(){
    struct sigaction act;
    act.sa_handler = &sigHandler;
    act.sa_flags = SA_RESETHAND | SA_NODEFER  ;

    if(sigaction(SIGPIPE, &act, NULL) == -1){
        printf("Error sigaction SIGPIPE 13 %s\n", strerror(errno));
        exit(EXIT_FAILURE);
    }

    printf("Current pid = %d , set SA_RESETHAND | SA_NODEFER for SIGPIPE 13, pause\n", getpid());
    pause();
    puts("Start 2 pause");
    pause();
}